<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html><head>
        <link rel="stylesheet" type="text/css" href="apidocs.css"/>
        <title>API docs for &ldquo;sympy.functions.combinatorial.numbers.harmonic&rdquo;</title>
        </head>
        <body><h1 class="class">Class s.f.c.n.harmonic(<a href="sympy.core.function.Function.html">Function</a>):</h1><span id="part">Part of <a href="sympy.functions.combinatorial.numbers.html">sympy.functions.combinatorial.numbers</a></span><div class="toplevel"><pre>Harmonic numbers

Usage
=====
    harmonic(n) gives the nth harmonic number, H_n

    harmonic(n, m) gives the nth generalized harmonic number
        of order m, H_{n,m}, where harmonic(n) == harmonic(n, 1)

Examples
========
    >>> from sympy import *

    >>> [harmonic(n) for n in range(6)]
    [0, 1, 3/2, 11/6, 25/12, 137/60]
    >>> [harmonic(n, 2) for n in range(6)]
    [0, 1, 5/4, 49/36, 205/144, 5269/3600]
    >>> harmonic(oo, 2)
    (1/6)*pi**2

Mathematical description
========================
    The nth harmonic number is given by 1 + 1/2 + 1/3 + ... + 1/n.
    More generally,
               n
              ___
             \       -m
      H    =  )     k   .
       n,m   /___
             k = 1

    As n -> oo, H_{n,m} -> zeta(m) (the Riemann zeta function)

References and further reading
==============================
    * http://en.wikipedia.org/wiki/Harmonic_number</pre></div><table class="children"><tr class="function"><td>Function</td><td><a href="#sympy.functions.combinatorial.numbers.harmonic.canonize">canonize</a></td><td><div><p>Returns a canonical form of cls applied to arguments args.</p>
</div></td></tr></table>
            <div class="function">
            <div class="functionHeader">def <a name="sympy.functions.combinatorial.numbers.harmonic.canonize">canonize(cls, n, m=None):</a></div>
            <div class="functionBody"><pre>Returns a canonical form of cls applied to arguments args.

The canonize() method is called when the class cls is about to be
instantiated and it should return either some simplified instance
(possible of some other class), or if the class cls should be
unmodified, return None.

Example of canonize() for the function "sign"
---------------------------------------------

@classmethod
def canonize(cls, arg):
    if arg is S.NaN:
        return S.NaN
    if arg is S.Zero: return S.One
    if arg.is_positive: return S.One
    if arg.is_negative: return S.NegativeOne
    if isinstance(arg, C.Mul):
        coeff, terms = arg.as_coeff_terms()
        if coeff is not S.One:
            return cls(coeff) * cls(C.Mul(*terms))</pre></div>
            </div></body>
        